home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Memphis Amiga Group / MAG General Utilities Disk 1 (1992-02)(Memphis Amiga Group).zip / MAG General Utilities Disk 1 (1992-02)(Memphis Amiga Group).adf / MultiPlayer / Programmers / GMOD.i < prev    next >
Text File  |  1991-05-09  |  4KB  |  108 lines

  1. *** Header file used for creating and calling GMOD modules ***
  2. * Public domain by Bryan Ford
  3.  
  4.     ifnd    BRY_GMOD_I
  5. BRY_GMOD_I    set    1
  6.  
  7.     ifnd    EXEC_TYPES_I
  8.     include "exec/types.i"
  9.     endc
  10.  
  11.  
  12. *** This is the layout of the first part of every GMOD module.
  13.  STRUCTURE    GMOD,0
  14.     ; The first four longwords contain various important values.
  15.     ULONG    gmod_ID            ; Must be 'GMOD'
  16.     ULONG    gmod_Maker        ; ID of creator program (ASCII, like IFF ID's)
  17.     ULONG    gmod_LoadAddress    ; Address at which to load module (0L = any)
  18.     ULONG    gmod_MaxVecOfs        ; Offset of end of vector table (numvecs+4)*4
  19.  
  20.     ; From here on are the entrypoints
  21.     ; (actual instructions, not just vector pointers)
  22.     LONG    gmod_InitMusic        ; Initialize the module
  23.     LONG    gmod_StartMusic        ; Start playing (d0.l = song number)
  24.     LONG    gmod_StopMusic        ; Stop playing
  25.     LONG    gmod_EndMusic        ; Shut down the module
  26.     LONG    gmod_Reserved        ; Pause
  27.     LONG    gmod_ContinueMusic    ; Restart after pause
  28.     LONG    gmod_VBlank50        ; VBlank interrupt (50Hz)
  29.     LONG    gmod_VBlank60        ; VBlank interrupt (60Hz)
  30.     LONG    gmod_Channel0        ; Channel 0 loaded interrupt
  31.     LONG    gmod_Channel1        ; Channel 1 loaded interrupt
  32.     LONG    gmod_Channel2        ; Channel 2 loaded interrupt
  33.     LONG    gmod_Channel3        ; Channel 3 loaded interrupt
  34.     LONG    gmod_GetNumSongs    ; Get number of songs (d0.l)
  35.     LONG    gmod_GetSongName    ; Get description of a song (d1.l) into (d0.p)
  36.     LONG    gmod_GetSongAuthor    ; Get the name of a song's author (d1.l) into (d0.p)
  37.     LONG    gmod_GetFrequency    ; Get the timing frequency for the song (d0.l)
  38.     LONG    gmod_TimerTick        ; Routine to call at specified frequency
  39.     LONG    gmod_GetMakerName    ; Get name of creator program
  40.     LONG    gmod_Hook        ; Specify a Hook to call on various events
  41.     LONG    gmod_Jump        ; Jump to sequence/time/whatever
  42.     LABEL    gmod_SIZEOF        ; Don't depend on this when playing a GMOD!
  43.  
  44.     ; Flags for the gmod_Hook call - similar to Intuition's IDCMP flags
  45.     BITDEF    GMODH,REPEAT,0        ; Call when music repeats
  46.     BITDEF    GMODH,SEQUENCE,1    ; Call when sequence changes
  47.  
  48.  
  49. *** Use these macros to help when playing GMOD modules.
  50. *** All of them assume that the pointer to the GMOD module is in a5.
  51.  
  52. * Branch if a vector offset (gmod_xxx) is in range
  53. gmodbin        macro    ; DReg,label
  54.         cmp.l    gmod_MaxVecOfs(a5),\1
  55.         bcs    \2
  56.         endm
  57.  
  58. * Branch if a vector offset (gmod_xxx) is out of range
  59. gmodbout    macro    ; DReg,label
  60.         cmp.l    gmod_MaxVecOfs(a5),\1
  61.         bcc    \2
  62.         endm
  63.  
  64. * Call a GMOD vector WITHOUT checking - you must first make sure it's there!
  65. gmodcall    macro    ; DReg
  66.         jsr    0(a5,\1)
  67.         endm
  68.  
  69. * Same as gmodcall, but with an immediate (as opposed to register) vector offset
  70. gmodcalli    macro    ; Offset
  71.         jsr    \1(a5)
  72.         endm
  73.  
  74. * This is what you'll usually use when calling GMOD entrypoints -
  75. * it first checks to make sure the entrypoint is available, THEN calls
  76. * it.  The GMOD pointer must be in a5, and the vector offset must
  77. * be in some data register.
  78. gmodmaycall    macro    ; DReg
  79.         cmp.l    gmod_MaxVecOfs(a5),\1
  80.         dc.w    $6404        ; bra.s *+2
  81.         gmodcall \1
  82.         endm
  83.  
  84.  
  85. *** Use these macros if you are DEFINING a GMOD header.  This makes it
  86. *** easier if you don't happen to know the lengths of the various instructions
  87. *** by memory.
  88.  
  89. * Do-nothing entrypoint - stick this in entrypoints you don't need or can't support
  90. gmodnop        macro            ; Do-nothing entry in a GMOD header
  91.         rts
  92.         nop
  93.         endm
  94.  
  95. * Branch to some other location (makes the GMOD header act like a jump table)
  96. gmodbra        macro    ; <label>    ; 4-byte branch.
  97.         jmp    \1(pc)        ; (Some assemblers would optimize down a bra.w.)
  98.         endm
  99.  
  100. * The following macro is useful for a few entrypoints like GetNumSongs
  101. * where you just need to return a small constant value.
  102. gmodq        macro    ; const        ; Return quick constant
  103.         moveq    #\1,d0
  104.         rts
  105.         endm
  106.  
  107.     endc
  108.